<?php
Route::domain(env('MANAGE_DOMAIN'))
    ->prefix("api")
    ->group(function ($routes) {

        $routes->get('/test', 'HomeController@test');
        $routes->group(['prefix' => 'auth'], function ($routes) {
            $routes->post('/login', 'LoginController@index');
            $routes->get('/captcha', 'LoginController@captcha');
            $routes->delete('/logout', 'LoginController@logout');
        });

        $routes->group(['middleware' => "manage"], function ($routes) {
            $routes->post('/upload', 'HomeController@upload'); //上传图片
            //首页
            $routes->get('/', 'HomeController@index');
            $routes->get('/dashboard/intraday', 'HomeController@intraday');
            $routes->get('/dashboard/close/apply', 'HomeController@closeApply');

            // 平台管理员的首页
            $routes->get('/manageIndex', 'HomeController@manageIndex');

            //管理员
            $routes->group(['prefix' => 'user'], function ($routes) {
                $routes->get('/me', 'UserController@me');
                $routes->get('/list', 'UserController@index');
                $routes->get('/detail/{id}', 'UserController@detail');
                $routes->get('/export', 'UserController@export'); //导出
                $routes->get('/import', 'UserController@import');//导入

                $routes->put('/edit/{id}', 'UserController@update'); //更新
                $routes->post('/edit', 'UserController@update');//编辑
                $routes->patch('/password/{id}', 'UserController@reset_pass'); //更新密码
                $routes->delete('/{id}', 'UserController@delete'); //删除
            });

            //订单
            $routes->group(['prefix' => 'order'], function ($routes) {
                $routes->get('/', 'OrderController@index');
                $routes->get('/detail/{id}', 'OrderController@detail');
                $routes->get('/export', 'OrderController@export_order'); //导出

                $routes->get('/import', 'OrderController@import');//导入
                $routes->get('/printer_label', 'OrderController@printer_label');//打印品单
                $routes->post('/printer', 'OrderController@printer');//打印订单
                $routes->post('/accept', 'OrderController@accept'); //确认接单
                $routes->get('/printer_stat', 'OrderController@printer_stat');//打印订单-统计数据
                $routes->get('printer/task', 'OrderController@task');//打印订单任务、
                $routes->get('/stat_status', 'OrderController@stat_status');//订单状态统计
                $routes->get('/init_filter', 'OrderController@init_filter');//订单筛选条件

                $routes->put('/edit/{id}', 'OrderController@update'); //更新
                $routes->put('/edit_note/{id}', 'OrderController@update_note'); //更新备注
                $routes->post('/edit', 'OrderController@update');//编辑
                $routes->post('refund/{id}', 'OrderController@refund');//退款/部分退款
                $routes->delete('/{id}', 'OrderController@delete'); //删除
            });

            //菜单
            $routes->group(['prefix' => 'menus'], function ($routes) {
                $routes->get('/', 'MenusController@index');
                $routes->get('/routes', 'MenusController@routes');
                $routes->get('/options', 'MenusController@options');
                $routes->get('/detail/{id}', 'MenusController@detail');
                $routes->put('/edit/{id}', 'MenusController@update');
                $routes->post('/edit', 'MenusController@update');

                $routes->delete('/{id}', 'MenusController@delete');
            });

            //角色
            $routes->group(['prefix' => 'roles'], function ($routes) {
                $routes->get('/', 'RolesController@index');
                $routes->get('/detail/{id}', 'RolesController@detail');
                $routes->get('/options', 'RolesController@options'); //所有角色->用于分类选择
                $routes->get('/menuIds/{id}', 'RolesController@menu_ids');
                $routes->put('/auth_menu/{id}', 'RolesController@auth_menu'); //添加菜单
                $routes->put('/edit/{id}', 'RolesController@update');
                $routes->post('/edit', 'RolesController@update');
                $routes->delete('/{id}', 'RolesController@delete');

            });

            // 会员
            $routes->group(['prefix' => 'member'], function ($routes) {
                $routes->get('/', 'MemberController@index');
                $routes->get('/detail/{id}', 'MemberController@detail');
                $routes->put('/integral/{id}', 'MemberController@update_integral'); //增加/减少积分
                $routes->get('/options', 'MemberController@options'); //所有角色->用于分类选择
                $routes->put('/edit/{id}', 'MemberController@update');
                $routes->delete('/{id}', 'MemberController@delete');
            });

            //字典
            $routes->group(['prefix' => 'dict'], function ($routes) {
                $routes->get('/', 'DictController@index');
                $routes->get('/{typeCode}/options', 'DictController@options');
                $routes->get('/detail/{id}', 'RolesController@detail');
                $routes->get('/menuIds/{id}', 'RolesController@menu_ids');
                $routes->put('/auth_menu/{id}', 'RolesController@auth_menu'); //添加菜单
                $routes->put('/edit/{id}', 'RolesController@update');
                $routes->post('/edit', 'RolesController@update');
                $routes->delete('/{id}', 'RolesController@delete');
            });

            //楼层
            $routes->group(['prefix' => 'lou-ddress'], function ($routes) {
                $routes->get('/', 'LouAddressController@index');
                $routes->get('/detail/{id}', 'LouAddressController@detail');
                $routes->put('/edit/{id}', 'LouAddressController@update');
                $routes->post('/edit', 'LouAddressController@update');
                $routes->post('/import', 'LouAddressController@import');
                $routes->delete('/{id}', 'LouAddressController@delete');
            });

            //打印机
            $routes->group(['prefix' => 'printer'], function ($routes) {
                $routes->get('/', 'PrinterController@index');
                $routes->get('/detail/{id}', 'PrinterController@detail');
                $routes->put('/edit/{id}', 'PrinterController@update');
                $routes->post('/edit', 'PrinterController@update');
                $routes->post('/init/{id}', 'PrinterController@init');
                $routes->post('/clear/{id}', 'PrinterController@clear');
                $routes->delete('/{id}', 'PrinterController@delete');
            });

            //商铺
            $routes->group(['prefix' => 'supplier'], function ($routes) {
                $routes->get('/', 'SupplierController@index');
                $routes->get('/init', 'SupplierController@init');
                $routes->get('/options', 'SupplierController@options'); // 所有角色->用于分类选择
                $routes->get('/detail/{id}', 'SupplierController@detail');
                $routes->post('/stat', 'SupplierController@stat');
                $routes->put('/edit/{id}', 'SupplierController@update');
                $routes->post('/edit', 'SupplierController@update');
                $routes->delete('/{id}', 'SupplierController@delete');
            });

            //商铺分类/档口
            $routes->group(['prefix' => 'stall'], function ($routes) {
                $routes->get('/', 'StallController@index');
                $routes->get('/detail/{id}', 'StallController@detail');
                $routes->put('/edit/{id}', 'StallController@update');
                $routes->post('/edit', 'StallController@update');
                $routes->delete('/{id}', 'StallController@delete');
            });

            //财务统计
            $routes->group(['prefix' => 'stat'], function ($routes) {
                $routes->get('/finance', 'StatController@finance');
                $routes->get('/shop', 'StatController@shop');
                $routes->get('/stall', 'StatController@stall');
                $routes->get('/product', 'StatController@product');
                $routes->get('/export', 'StatController@export');
            });

            // 商户
            $routes->group(['prefix' => 'shop'], function ($routes) {
                $routes->get('/', 'ShopController@index');
                $routes->get('/detail/{id}', 'ShopController@detail');
                $routes->put('/edit/{id}', 'ShopController@update');
                $routes->post('/edit', 'ShopController@update');
                $routes->delete('/{id}', 'ShopController@delete');
            });

            // 微信商户支付
            $routes->group(['prefix' => 'wemch'], function ($routes) {
                $routes->get('/', 'WemchController@index');
                $routes->get('/detail/{id}', 'WemchController@detail');
                $routes->put('/edit/{id}', 'WemchController@update');
                $routes->post('/edit', 'WemchController@update');
                $routes->delete('/{id}', 'WemchController@delete');
            });

            //文章
            $routes->group(['prefix' => 'article'], function ($routes) {

                //分类
                $routes->group(['prefix' => 'category'], function ($routes) {
                    $routes->get('/', 'CategoryController@index');
                    $routes->get('/detail/{id}', 'CategoryController@detail');
                    $routes->put('/edit/{id}', 'CategoryController@update');
                    $routes->post('/add', 'CategoryController@update');
                    $routes->delete('/{id}', 'CategoryController@delete');
                    $routes->get('/options', 'CategoryController@options');
                });

                $routes->get('/', 'ArticleController@index');
                $routes->get('/detail/{id}', 'ArticleController@detail'); //详情
                $routes->put('/edit/{id}', 'ArticleController@update');
                $routes->post('/create', 'ArticleController@update');
                $routes->delete('/{id}', 'ArticleController@delete'); //删除文章
            });

            //园区
            $routes->group(['prefix' => 'park'], function ($routes) {
                $routes->get('/', 'ParkController@index');
                $routes->get('/detail/{id}', 'ParkController@detail');
                $routes->get('/options', 'ParkController@options'); //园区选项
                $routes->put('/edit/{id}', 'ParkController@update');
                $routes->post('/edit', 'ParkController@update');
                $routes->delete('/{id}', 'ParkController@delete');
            });

            //每日菜单
            $routes->group(['prefix' => 'daily-menu'], function ($routes) {
                $routes->get('/', 'DailyMenuController@index');
                $routes->get('/options', 'DailyMenuController@options');
                $routes->get('/detail/{id}', 'DailyMenuController@detail');
                $routes->get('/products/{id}', 'DailyMenuController@products'); //菜单对应的产品
                $routes->post('/products/{id}', 'DailyMenuController@add_products'); //菜单添加菜品
                $routes->post('/copy/{id}', 'DailyMenuController@copy'); //菜单复制
                $routes->get('/product-options/{id}', 'DailyMenuController@prod_options'); //菜单待选产品
                $routes->put('/edit/{id}', 'DailyMenuController@update');
                $routes->post('/edit', 'DailyMenuController@update');
                $routes->post('/sort', 'DailyMenuController@sort'); //排序
                $routes->delete('/{id}', 'DailyMenuController@delete');
                $routes->delete('/product/{id}', 'DailyMenuController@del_product');
            });

            //商品
            $routes->group(['prefix' => 'product'], function ($routes) {

                //分类
                $routes->group(['prefix' => 'category'], function ($routes) {
                    $routes->get('/', 'ProductCategoryController@index');
                    $routes->delete('/{id}', 'ProductCategoryController@delete');
                    $routes->get('/detail/{id}', 'ProductCategoryController@detail');
                    $routes->put('/edit/{id}', 'ProductCategoryController@update');
                    $routes->post('/add', 'ProductCategoryController@update');
                });

                $routes->get('/', 'ProductController@index');
                $routes->get('/detail/{id}', 'ProductController@detail');
                $routes->get('options', 'ProductController@options');
                $routes->get('search_options', 'ProductController@search_options');
                $routes->put('/edit/{id}', 'ProductController@update');
                $routes->post('/add', 'ProductController@update');
                $routes->post('/copy/{id}', 'ProductController@copy'); //复制
                $routes->delete('/{id}', 'ProductController@delete');

            });

            //意见反馈
            $routes->group(['prefix' => 'advice'], function ($routes) {
                $routes->get('/', 'AdviceController@index');
                $routes->get('/detail/{id}', 'AdviceController@detail');
                $routes->put('/edit/{id}', 'AdviceController@update');
                $routes->post('/edit', 'AdviceController@update');
                $routes->delete('/{id}', 'AdviceController@delete');
            });


        });

    });


